package com.qs.javame.thread1028.blockqueue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

public class Test2 {

    public static void main(String[] args) {
        BlockingQueue<String> blockingQueue = new ArrayBlockingQueue<>(5);

        //返回false
        boolean removed = blockingQueue.remove("aaa");
        System.out.println("==>>" + removed);

        //返回null
        String element = blockingQueue.poll();
        System.out.println("==>>" + element);

        try {
            //等待3s，获取不到元素，则返回null
            String element2 = blockingQueue.poll(3, TimeUnit.SECONDS);
            System.out.println("===>>" + element2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
